﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using thinger.MTHDAL;
using thinger.MTHModels;

namespace thinger.MTHDLL
{
    public class ActualDataManage
    {
        private ActualDataServer actualDataServer = new ActualDataServer();

        public List<ActualData> ActualByTime(string start, string end)
        {
            try
            {
                List<ActualData> actualDatas = new List<ActualData>();
                DataTable dataTable = actualDataServer.ActualDataByTime(start, end);
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    ActualData actualData = new ActualData()
                    {
                        InsertTime = dataTable.Rows[i]["InsertTime"].ToString().Trim(),
                        Station1Temp = dataTable.Rows[i]["Station1Temp"].ToString().Trim(),
                        Station1Humidity = dataTable.Rows[i]["Station1Humidity"].ToString().Trim(),
                        Station2Temp = dataTable.Rows[i]["Station2Temp"].ToString().Trim(),
                        Station2Humidity = dataTable.Rows[i]["Station2Humidity"].ToString().Trim(),
                        Station3Temp = dataTable.Rows[i]["Station3Temp"].ToString().Trim(),
                        Station3Humidity = dataTable.Rows[i]["Station3Humidity"].ToString().Trim(),
                        Station4Temp = dataTable.Rows[i]["Station4Temp"].ToString().Trim(),
                        Station4Humidity = dataTable.Rows[i]["Station4Humidity"].ToString().Trim(),
                        Station5Temp = dataTable.Rows[i]["Station5Temp"].ToString().Trim(),
                        Station5Humidity = dataTable.Rows[i]["Station5Humidity"].ToString().Trim(),
                        Station6Temp = dataTable.Rows[i]["Station6Temp"].ToString().Trim(),
                        Station6Humidity = dataTable.Rows[i]["Station6Humidity"].ToString().Trim(),
                    };

                    actualDatas.Add(actualData);
                }
                return actualDatas;
            }
            catch (Exception)
            {

                return null;
            }

        }

        public int AddActual(ActualData actualData) 
        {
            try
            {
                return actualDataServer.AddActual(actualData);
            }
            catch (Exception)
            {

                return -1;
            }
            
        }

        public DataTable ActualByTimeTable(string start, string end)
        {
            try
            {
                return actualDataServer.ActualDataByTime(start, end);
            }
            catch (Exception)
            {

                return null;
            }
            
            
        }


    }
}
